<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增分享</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
</head>
<body>
<div>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">分享来自：</label>
            <div class="layui-input-block">
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入分享人" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">组号：</label>
            <div class="layui-input-block">
                <select name="groupid" lay-verify="required">
                    <option value=""></option>
                    <option value="1">第一组</option>
                    <option value="2">第二组</option>
                    <option value="3">第三组</option>
                </select>
            </div>
        </div>

<!--        <div class="layui-form-item layui-form-text">-->
<!--            <label class="layui-form-label">主题：</label>-->
<!--            <div class="layui-input-block">-->
<!--                <textarea name="title" placeholder="请输入主题" class="layui-textarea"></textarea>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">新增分享</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script src="/layui/layui.js"></script>
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form,
                $=layui.$;

            //提交
            form.on('submit(formDemo)', function(data){

                //页面请求接口 Ajax data.field 获取表单数据 等价于 原来 $("#fm1").serialize()
                $.post("/api/users/add.do",data.field,function (res){
                    if(res.code==0){
                        //成功
                        location.href="index.html";
                    }else {
                        //弹出
                        layer.msg("亲，新增失败啦！");
                    }
                })
                return false;
            });
        });
    </script>
</div>
</body>
</html>